<template>
  <button type="button" @click="$emit('btnClick','数据')">触发父组件事件</button>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
	name:'child-emits',
	emits:{
		// 带有验证函数,可以用来验证参数是否有效
		btnClick:function (payload){
		  console.log('payload',payload);
		  
		  if (payload.email && payload.password) {
			return true
		  } else {
			console.warn(`Invalid submit event payload!`)
			return false
		  }
		}
	}
})
</script>

<style scoped>
a {
  color: #42b983;
}

label {
  margin: 0 0.5em;
  font-weight: bold;
}

code {
  background-color: #eee;
  padding: 2px 4px;
  border-radius: 4px;
  color: #304455;
}
</style>
